<!-- Modal -->
<div class="modal" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-task" style="width: 1180px;padding: 10px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">Modal title</h4>
            </div>
            <div class="modal-body" style="padding: 0;">
                <div style="min-height: 420px;overflow: hidden;overflow-y: auto;">
                    <iframe src='about:blank' width='100%' height="0" frameborder='no' border=0 marginwidth=0
                            marginheight=0 scrolling=0 allowtransparency='yes'></iframe>
                </div>
            </div>
            <div class="modal-footer" style="margin: 0;text-align: center">
                <button type="button" class="btn btn-primary j_fireSubmit">保存/提交</button>
                <button type="button" class="btn btn-default j_firePreview">快速预览</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div><!-- /.modal -->
        <style>
            .modal-dialog-task{visibility:hidden;}
            .modal-footer{
                padding: 10px;
            }
        </style>
<script>
    //引入modal模块的javascript
    //j_modalIframe 编辑
    $(".lists").on('click','.j_modalIframe',function(ev){
        var target=ev.currentTarget,
                readOnly=false,
                url=target.getAttribute('href');
        if(target.title.indexOf('查看')>-1)readOnly=true;
        modalFrame&&modalFrame(url,{title:target.title,readOnly:readOnly});
        return false;
    });

    $(document.body).on('click','.j_createNew',function(ev){
        var target=ev.currentTarget;
        modalFrame && modalFrame(target.getAttribute('data-url'),{title:'[新建]'+target.title});
        return false;
    });


    var modal = window.modal = $("#myModal");
    modal.on('hidden.bs.modal', function () {
        modal.find('iframe').height(0);
    });
    $(".j_fireSubmit").click(function (ev) {
        var s = $('#submitButton', modal.find('iframe').contents());
        if(s.length){
            s.trigger('click');
        }else{
            alert('这个测试用例不是你的!!!');
        }

        return false;
    });
    $(".j_firePreview").click(function (ev) {
        var p = $('#preview', modal.find('iframe').contents());
        p.trigger('click');
        return false;
    });
    function modalFrame(url, option) {
        var op = option;
        op.title && $("#myModalLabel", modal).html(op.title);
        if(op.readOnly){
            $('.j_fireSubmit',modal).hide();
        }else{
            $('.j_fireSubmit',modal).show();
        }

        url && modal.find('iframe').attr('src', url);
        modal.modal(option || {});
    }

</script>